package com.jsptags.navigation.pager;

import com.jsptags.navigation.pager.parser.PageTagExport;
import com.jsptags.navigation.pager.parser.ParseException;
import com.jsptags.navigation.pager.parser.TagExportParser;
import javax.servlet.jsp.tagext.*;

public class PageTagExtraInfo extends TagExtraInfo {

	static Class<String> strClass; /* synthetic field */
	static Class<Integer> intClass; /* synthetic field */

	@SuppressWarnings("unchecked")
	public VariableInfo[] getVariableInfo(TagData tagdata) {
		try {
			String s;
			s = tagdata.getAttributeString("export");
			if (s == null)
				return null;
			VariableInfo avariableinfo[];
			PageTagExport pagetagexport = TagExportParser.parsePageTagExport(s);
			int i = 0;
			if (pagetagexport.getPageUrl() != null)
				i++;
			if (pagetagexport.getPageNumber() != null)
				i++;
			if (pagetagexport.getFirstItem() != null)
				i++;
			if (pagetagexport.getLastItem() != null)
				i++;
			avariableinfo = new VariableInfo[i];
			int j = 0;
			String s1;
			if ((s1 = pagetagexport.getPageUrl()) != null)
				avariableinfo[j++] = new VariableInfo(
						s1,
						(strClass == null
								&& (strClass = class$("java.lang.String", false)) == null ? strClass
								: strClass).getName(), true, 0);
			if ((s1 = pagetagexport.getPageNumber()) != null)
				avariableinfo[j++] = new VariableInfo(s1,
						(intClass == null
								&& (intClass = class$("java.lang.Integer",
										false)) == null ? intClass : intClass)
								.getName(), true, 0);
			if ((s1 = pagetagexport.getFirstItem()) != null)
				avariableinfo[j++] = new VariableInfo(s1,
						(intClass == null
								&& (intClass = class$("java.lang.Integer",
										false)) == null ? intClass : intClass)
								.getName(), true, 0);
			if ((s1 = pagetagexport.getLastItem()) != null)
				avariableinfo[j++] = new VariableInfo(s1,
						(intClass == null
								&& (intClass = class$("java.lang.Integer",
										false)) == null ? intClass : intClass)
								.getName(), true, 0);
			return avariableinfo;
		} catch (ParseException e) {
			return new VariableInfo[0];
		}
	}

	public boolean isValid(TagData tagdata) {
		String s = tagdata.getAttributeString("export");
		if (s != null)
			try {
				TagExportParser.parsePageTagExport(s);
			} catch (ParseException parseexception) {
				return false;
			}
		return true;
	}

	@SuppressWarnings("unchecked")
	static Class class$(String s, boolean flag) {
		try {
			Class clazz = Class.forName(s);
			if (flag) {
				return null;
			} else {
				return clazz;
			}
		} catch (ClassNotFoundException e) {
			throw new NoClassDefFoundError(e.getMessage());
		}

	}
}
